s1 = "eehhh12345"
s2 = "12345ee"

# 找出相同元素的下标
def fun1(s1, s2):
    i = -1
    l1 = []
    for n in s1:
        i += 1
        if n in s2:
            l1.append(i)
    return l1

b = fun1(s1, s2)
# 对列表进行划分
def fun2(l):
    l2 = []

    if len(l) == 1:
        return l

    for i in range(0, len(l)):
        if l[i]+1 == l[i+1] and i == 0:
            for u in l[i:i+2]:
                l2.append(u)

        elif l[i]+1 == l[i+1] and i > 0:
            l2.append(l[i+1])

        elif l[i]+1 != l[i:i+1]:
            return l2

        if i == len(l)-2:
            return l2


# 检测对应下标的元素是否在另一个字符串中
def fun3(s1, s2):
    l1 = fun1(s1, s2)
    l3 = []
    while len(l1) > 0:
        l3.append(fun2(l1))
        del l1[0:len(fun2(fun2(l1)))]

    l5 = []
    for i in l3:
        if s1[i[0]:i[-1]+1] in s2:
            l5.append(s1[i[0]:i[-1]+1])

    return max(l5)

print(fun3(s1, s2))


s3 = "12rf"
s4 = "1234"
l1 = [1, 2, 3]
l2 = []
l2.append(l1[0:100])
# 方法2
def lcs(str1, str2):
    res = ''
    left = 0
    for i in range(len(str1)+1):
        if str1[left:i+1] in str2:
            res = str1[left:i+1]
        else:
            left += 1
    return res

print(lcs(s3, s4))

for i in range(len(s3)+1):
    print(i)


print(l1[0:8])        # 不会报错
print(s3[0:8])
print(len(l1[0:9]))



for i in l1[0:100]:
    print(i)









